package com.yunhe.inter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;

import com.yunhe.bean.PageBean;
import com.yunhe.bean.UserTier;
import com.yunhe.util.SqlSessionFactoryUtil;



public class UserDaoImpl implements UserService {
   //��֤�û���
	@Override
	public UserTier checkUser(String userName) {
		SqlSession sqlSession=SqlSessionFactoryUtil.openSqlSession();
		UserDao userDao=sqlSession.getMapper(UserDao.class);
	    UserTier user=userDao.RegUser(userName);
	    sqlSession.close();
		return user;
	}

	@Override
	public UserTier Login(String userName, String passWord) {
		// TODO Auto-generated method stub
		SqlSession sqlSession=SqlSessionFactoryUtil.openSqlSession();
		LogDao mapper=sqlSession.getMapper(LogDao.class);
	    UserTier ut=mapper.Login(userName, passWord);
	    sqlSession.close();
		return ut;
	}

	@Override
	public Map loadNews(PageBean pb) {
		SqlSession sqlSession=SqlSessionFactoryUtil.openSqlSession();
        AdminDao admindao=sqlSession.getMapper(AdminDao.class);
        List<UserTier> UserTierlist=admindao.queryNews(pb);
        int records =admindao.countNews();
        pb.setRecords(records);
        Map map=new HashMap();
        map.put("UserTier", UserTierlist);
		map.put("pageBean", pb);
		return map;
	}

	
	

	
	

	
}
